<template>
	<view class="container">
		<view class="module">
			 
			<!-- view class="module-item" @click="follow">
				<uni-icons color="#8acfcf" custom-prefix="iconfont" type="icon-record" size="30"    class="iconBox" style="font-size: 30px;background-color: #fff;"></uni-icons>
				<text class="text">跟进记录</text>
			</view> -->
			<view class="module-item" @click="customer">
				<uni-icons color="#55b7f4" custom-prefix="iconfont" type="icon-uf_customer" size="30"  class="iconBox" style="font-size: 30px;background-color: #fff;"></uni-icons>
				<text class="text">全部客户</text>
			</view>
			
		
			<view class="module-item" @click="projectRemarks">
				<uni-icons color="#abdcef" custom-prefix="iconfont" type="icon-qc-report" size="30"  class="iconBox" style="font-size: 30px;"></uni-icons>
				<text class="text">报备管理</text>
			</view>
			<view class="module-item" @click="saomaFn">
				<uni-icons  color="#ff8c2f" custom-prefix="iconfont" type="icon-icon_saoma_mian" size="30"  class="iconBox" style="font-size: 30px;background-color: #fff;"></uni-icons>
				<text class="text">扫码入库</text>
			</view>
			<view class="module-item" @click="WareHouse">
				<uni-icons color="#0cc3dd" custom-prefix="iconfont" type="icon-warehouse-" size="30"  class="iconBox" style="font-size: 30px;background-color: #fff;"></uni-icons>
				<text class="text">仓库</text>
			</view>
			<view class="module-item" @click="projectFiling">
				<uni-icons color="#ffc849" custom-prefix="iconfont" type="icon-Project" size="30"  class="iconBox" style="font-size: 30px;background-color: #fff;"></uni-icons>
				<text class="text">项目管理</text>
			</view>
			<view class="module-item" @click="repair">
				<uni-icons color="#80deea" custom-prefix="iconfont" type="icon-shouhouxiuligongshifuwu" size="30"  class="iconBox" style="font-size: 30px;background-color: #fff;"></uni-icons>
				<text class="text">维修管理</text>
			</view>
			<view class="module-item" @click="ebgineeCost">
				<uni-icons color="#ffc849" custom-prefix="iconfont" type="icon-repair01" size="30"  class="iconBox" style="font-size: 30px;background-color: #fff0d8;"></uni-icons>
				<text class="text">工程部管理</text>
			</view>
			<view class="module-item" @click="toTramsfer">
				<uni-icons color="#2cb8c4" custom-prefix="iconfont" type="icon-chukuguanli1" size="25"  class="iconBox" style="font-size: 30px" ></uni-icons>
				<text class="text">调拨单</text>
			</view>
			<view class="module-item" @click="order">
				<uni-icons color="#f6716c" custom-prefix="iconfont" type="icon-dingdan" size="30"  class="iconBox" style="font-size: 30px;"></uni-icons>
				<text class="text">租赁销售订单</text>
			</view>
			<view class="module-item" @click="out">
				<uni-icons color="#4dacff" custom-prefix="iconfont" type="icon-chukuguanli" size="25"  class="iconBox" style="font-size: 30px" ></uni-icons>
				<text class="text">出库单</text>
			</view>
			<view class="module-item" @click="backapplication">
				<uni-icons color="#ff7245" custom-prefix="iconfont" type="icon-apply" size="25"  class="iconBox" style="font-size: 30px" ></uni-icons>
				<text class="text">回货单</text>
			</view>
			<view class="module-item" @click="accountStatement">
				<uni-icons color="#f6716c" custom-prefix="iconfont" type="icon-yinhangduizhangdan" size="25"  class="iconBox" style="font-size: 30px" ></uni-icons>
				<text class="text">对账单</text>
			</view>
			<view class="module-item" @click="accountStatement">
				<uni-icons color="#f6716c" custom-prefix="iconfont" type="icon-yinhangduizhangdan" size="25"  class="iconBox" style="font-size: 30px" ></uni-icons>
				<text class="text">结算单</text>
			</view>
			<view class="module-item" @click="logisticsFn">
				<uni-icons color="#ffc849" custom-prefix="iconfont" type="icon-transport-fill1" size="45"  class="iconBox" style="font-size: 30px;background-color: #fff0d8;"></uni-icons>
				<text class="text">物流管理</text>
			</view>
			<view class="module-item" @click="receiptorder">
				<uni-icons color="#4dacff" custom-prefix="iconfont" type="icon-rukuguanli" size="50"  class="iconBox" style="font-size: 30px;background-color: #eef7ff;"></uni-icons>
				<text class="text">机器采购</text>
			</view>
			
			<view class="module-item" @click="product">
				<uni-icons color="#4dacff" custom-prefix="iconfont" type="icon-similar-product-fill" size="25"  class="iconBox" style="font-size: 30px;background-color: #eef7ff;"></uni-icons>
				<text class="text" >产品管理</text>
			</view>
			<view class="module-item" @click="machine">
				<uni-icons color="#4dacff" custom-prefix="iconfont" type="icon-foodmachine" size="25"  class="iconBox" style="font-size: 30px;background-color: #eef7ff;" ></uni-icons>
				<text class="text">机器管理</text>
			</view>
			
			
			
			
			<view class="module-item" @click="question">
				<uni-icons color="#33abe3" custom-prefix="iconfont" type="icon-lingyongshenqing
" size="25"  class="iconBox" style="font-size: 30px" ></uni-icons>
				<text class="text">问答</text>
			</view>
			
			
		</view>
		<!-- <view>
		      <u-notice-bar :text="text1"></u-notice-bar>
		    </view> -->
		
		<!-- 简报看板 -->
		<view class="briefing">
			<u-cell >
				<template #right-icon>
					<uni-icons @click="openSearch" type="gear" :size="18"></uni-icons>
				</template>
				<template #title>
					<view style="font-size: 15px;font-weight: 600;">简单看板 <span style="font-size: 12px;font-weight: 400;margin-left: 10px;">{{name}}/{{text}}</span></view>
				</template>
			</u-cell>
			<view class="board-Box">
				
				<view class="board">
					<view class="icon"><uni-icons color="#ff8c2f" custom-prefix="iconfont" type="icon-customer" class="iconBox" style='font-size: 18px' ></uni-icons></view>
					<view class="data border">
						<view class="title">总客户 </view>
						<view class="number"><span style="font-size: 16px;">{{infomation.customerNum}}</span>个</view>
					</view>
				</view>
				<view class="board">
					<view class="icon"><uni-icons color="#ff8c2f" custom-prefix="iconfont" type="icon-customer" class="iconBox" style='font-size: 18px' ></uni-icons></view>
					<view class="data">
						<view class="title">成交客户数 </view>
						<view class="number"><span style="font-size: 16px;">{{infomation.dealCustomerNum}}</span>个</view>
					</view>
				</view>
				<view class="board  " >
					<view class="icon"><uni-icons color="#f6716c" custom-prefix="iconfont" type="icon-order" class="iconBox" style='font-size: 18px' ></uni-icons></view>
					<view class="data border ">
						<view class="title">订单数量</view>
						<view class="number"><span style="font-size: 16px;">{{infomation.orderNum}}</span>个</view>
					</view>
				</view>
				<view class="board  " >
					<view class="icon"><uni-icons color="#f6716c" custom-prefix="iconfont" type="icon-order" class="iconBox" style='font-size: 18px' ></uni-icons></view>
					<view class="data  ">
						<view class="title">订单押金</view>
						<view class="number"><span style="font-size: 16px;">{{infomation.orderAmountSum}}</span>元</view>
					</view>
				</view>
				<view class="board">
					<view class="icon"><uni-icons color="#f6716c" custom-prefix="iconfont" type="icon-gongyingshangduizhang" class="iconBox" style='font-size: 18px' ></uni-icons></view>
					<view class="data border">
						<view class="title">订单押金预警</view>
						<view class="number"><span style="font-size: 16px;">{{infomation.warningCount}}</span>个</view>
					</view>
				</view>
				<view class="board">
					<view class="icon"><uni-icons color="#ffc849" custom-prefix="iconfont" type="icon-33statementlist" class="iconBox" style='font-size: 18px' ></uni-icons></view>
					<view class="data ">
						<view class="title">逾期金额</view>
						<view class="number"><span style="font-size: 16px;">{{infomation.overdueAmount}}</span>元</view>
					</view>
				</view>
				<view class="board">
					<view class="icon"><uni-icons color="#ffc849" custom-prefix="iconfont" type="icon-order" class="iconBox" style='font-size: 18px' ></uni-icons></view>
					<view class="data border">
						<view class="title">已结算订单数量</view>
						<view class="number"><span style="font-size: 16px;">{{infomation.settledOrderCount}}</span></view>
					</view>
				</view>
				
				<view class="board">
					<view class="icon"><uni-icons color="red" custom-prefix="iconfont" type="icon-kehuduizhang" class="iconBox" style='font-size: 18px' ></uni-icons></view>
					<view class="data ">
						<view class="title">已结算金额</view>
						<view class="number"><span style="font-size: 16px;">{{infomation.settledOrderAmountSum}}</span></view>
					</view>
				</view>
				<!-- <view class="board">
					<view class="icon"><uni-icons color="#4dacff" custom-prefix="iconfont" type="icon-foodmachine" class="iconBox" style='font-size: 18px' ></uni-icons></view>
					<view class="data border">
						<view class="title">机器可用数</view>
						<view class="number"><span style="font-size: 16px;">{{infomation.machines}}</span>个</view>
					</view>
				</view> -->
				<!-- <view class="board">
					<view class="icon"><uni-icons color="#f6716c" custom-prefix="iconfont" type="icon-order" class="iconBox" style='font-size: 18px' ></uni-icons></view>
					<view class="data ">
						<view class="title">已完成结算订单数量</view>
						<view class="number"><span style="font-size: 16px;">{{infomation.finishOrders}}</span>个</view>
					</view>
				</view> -->
			</view>
		</view>
		<!-- 业绩目标 -->
		<view class="briefing">
			<u-cell >
				<template #right-icon>
					<uni-icons type="gear" :size="18"></uni-icons>
				</template>
				<template #title>
					<view style="font-size: 15px;font-weight: 600;">业绩目标 <span style="font-size: 12px;font-weight: 400;margin-left: 10px;">{{name}}/{{text}}</span></view>
				</template>
			</u-cell>
			<view class="achievement">
				 <view class="charts-box">
				    <qiun-data-charts 
				      type="gauge"
				      :opts="opts"
				      :chartData="chartData"
				    />
				  </view>
				<view class="target">
					<view>
						<view>完成值</view>
						<view>0.00元</view>
					</view>
					<view>
						<view>目标值</view>
						<view>未设置</view>
					</view>
					<view>
						<view>未完成值</view>
						<view>0.00元</view>
					</view>
				</view>
				<view class="details">
					查看业绩详情
				</view>
			</view>
		</view>
		<!-- PK榜 -->
		<view class="briefing">
			<u-cell >
				<template #right-icon>
					<uni-icons type="gear" :size="18"></uni-icons>
				</template>
				<template #title>
					<view style="font-size: 15px;font-weight: 600;">PK榜 <span style="font-size: 12px;font-weight: 400;margin-left: 10px;">{{name}}/{{text}}</span></view>
				</template>
			</u-cell>
			<view class="PK">
				<view class="title">签订合同PK榜</view>
				<view class="middle-box">当前榜单暂无排名</view>
				<view class="details">查看详情</view>
			</view>
			
		</view>
		<!-- 遗忘提醒 -->
		<view class="briefing">
			<u-cell>
				<template #icon>
					<uni-icons type="notification" color="#6ee6c6" size="24"></uni-icons>
				</template>
				<template #title>
					<view style="font-size: 15px;font-weight: 600;">遗忘提醒 <span style="font-size: 12px;font-weight: 400;margin-left: 10px;">{{name}}/{{text}}</span></view>
				</template>
			</u-cell>
			<view class="RemindBox">
				<view class="remind">
					<view class="color">0</view>
					<view  class="words">一周到两周未联系</view>
				</view>
				<view class="remind">
					<view  class="color">0</view>
					<view  class="words">两周到一月未联系</view>
				</view>
				<view class="remind">
					<view  class="color">0</view>
					<view class="words">一月到两月未联系</view>
				</view>
				<view class="remind">
					<view  class="color">0</view>
					<view class="words">两月以上未联系</view>
				</view>
			</view>
		</view>
		<!-- 客户 -->
		<view class="briefing">
			<u-cell>
				<template #title>
					<view style="font-size: 15px;font-weight: 600;">客户 <span style="font-size: 12px;font-weight: 400;margin-left: 10px;">{{name}}/{{text}}</span></view>
				</template>
			</u-cell>
			<view >
				<business-customer></business-customer>
				<view class="customer">
					<view class="customerBox">
						<view class="desc">订单数量</view>
						<view class="number"><span style="font-size: 16px;font-weight: 600;">0</span>个</view>
					</view>
					<view class="customerBox">
						<view class="desc">订单总金额</view>
						<view class="number"><span style="font-size: 16px;font-weight: 600;">0</span>个</view>
					</view>
					<view class="customerBox">
						<view class="desc">已收款</view>
						<view class="number"><span style="font-size: 16px;font-weight: 600;">0</span>个</view>
					</view>
					<view class="customerBox">
						<view class="desc">未收款</view>
						<view class="number"><span style="font-size: 16px;font-weight: 600;">0</span>个</view>
					</view>
					<view class="customerBox">
						<view class="desc">逾期金额</view>
						<view class="number"><span style="font-size: 16px;font-weight: 600;">0</span>个</view>
					</view>
					<view class="customerBox">
						<view class="desc">优质客户</view>
						<view class="number"><span style="font-size: 16px;font-weight: 600;">0</span>个</view>
					</view>
					<view class="customerBox">
						<view class="desc">机器可用数量</view>
						<view class="number"><span style="font-size: 16px;font-weight: 600;">0.0%</span>个</view>
					</view>
					<view class="customerBox">
						<view class="desc">已完成结算订单数量</view>
						<view class="number"><span style="font-size: 16px;font-weight: 600;">0</span>个</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 资金管理 -->
		<view class="briefing" style="padding-bottom: 20px;">
			<u-cell>
				<template #title>
					<view style="font-size: 15px;font-weight: 600;">资金管理 <span style="font-size: 12px;font-weight: 400;margin-left: 10px;">{{name}}/{{text}}</span></view>
				</template>
			</u-cell>
			<view class="capitalBox">
				<view class="capital">
					<u-icon class="icon" name="photo" color="#2979ff" size="24"></u-icon>
					<view class="desc">
						<view>应收未收</view>
						<view><span class="color">0.00</span>元</view>
					</view>
				</view>
				<view class="capital">
					<u-icon class="icon" name="photo" color="#2979ff" size="24"></u-icon>
					<view class="desc">
						<view>回款核销</view>
						<view><span class="color">0.00</span>元</view>
					</view>
				</view>
				<view class="capital">
					<u-icon class="icon" name="photo" color="#2979ff" size="24"></u-icon>
					<view class="desc">
						<view>回款坏账</view>
						<view><span class="color">0.00</span>元</view>
					</view>
				</view>
				<view class="capital">
					<u-icon class="icon" name="photo" color="#2979ff" size="24"></u-icon>
					<view class="desc">
						<view>红冲</view>
						<view><span class="color">0.00</span>元</view>
					</view>
				</view>
				<view class="capital">
					<u-icon class="icon" name="photo" color="#2979ff" size="24"></u-icon>
					<view class="desc">
						<view>应收未收</view>
						<view><span class="color">0.00</span>元</view>
					</view>
				</view>
				
			</view>
		</view>
		<u-popup :show="showPop" mode="right" customStyle="margin-top:44px;width:250px" :closeable="true" :closeOnClickOverlay="true" @close="closePop">
		        <view style="margin-top: 15px;padding-left: 6px;margin-right: 5px;">
		          <view style="border-bottom: #2979ff 2px solid;color: #2979ff;font-size: 18px;margin-bottom: 10px;padding-bottom: 5px;">
		          	<text >选择筛选条件</text>
		          </view>
				  <view class="">
				  	<text>时间选择</text>
					<view class="timeSearch " style="">
						<view @click="checked(1)" :class=" {bcolor1:active==1}" class="timeItem">
							<span>今日</span>
						</view>
						<view@click="checked(2)" :class=" {bcolor1:active==2}" class="timeItem">
							<span>本周</span>
						</view>
						<view@click="checked(3)" :class=" {bcolor1:active==3}" class="timeItem">
							<span>本月</span>
						</view>
						<view@click="checked(4)" :class=" {bcolor1:active==4}" class="timeItem">
							<span>昨日</span>
						</view>
						<view@click="checked(5)" :class=" {bcolor1:active==5}" class="timeItem">
							<span>上周</span>
						</view>
						<view@click="checked(6)" :class=" {bcolor1:active==6}" class="timeItem">
						  <span>上月</span>
						</view>
					</view>
				  </view>
		        </view>
			</u-popup>
		<!-- 手机端tabbar页面得要 -->
		<view style="width: 100%; height: 30px;"></view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import {getVersion} from '@/api/edition.js'
	import {listInfo,getindexInfo,getsmplenessInfo} from '@/api/index.js'
	import {getUserProfile} from '@/api/system/user.js'
	import businessCustomer  from "@/pages/dialog/echart/customer.vue"
	import {searchMachineApi} from '@/api/machine/machine.js'
	import {addregidApi} from '@/api/JPSh.js'
	export default{
		components:{
			businessCustomer
		},
		data(){
		// 首先需要通过 uni.requireNativePlugin("ModuleName") 获取 module
		// var jpushModule = uni.requireNativePlugin("JG-JPush")
			return{
			
				clid:'',
				// 登录设备regid
				// jpushModule: uni.requireNativePlugin("JG-JPush"),
				connectStatus: '未链接',
				deviceToken: '',
				udid: '',
				registrationID: '未获得',
				appkey: '',
				
				wgtinfoVersion:'',
				form:{
					machineNo:''
				},
				infomation:{},
				name:'',
				userId:'',
				position:'',
				  chartData: {},
				      //您可以通过修改 config-ucharts.js 文件中下标为 ['gauge'] 的节点来配置全局默认参数，如都是默认参数，此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式，达到页面简洁的需求。
				      opts: {
				        color: ["#f27674","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
				        padding: undefined,
				        title: {
				          name: "完成率0.00%",
				          fontSize: 15,
				          color: "#f27674",
				          offsetY: 100
				        },
				        subtitle: {
				          name: "实时速度",
				          fontSize: 15,
				          color: "#fff",
				          offsetY: -50
				        },
				        extra: {
				          gauge: {
				            type: "default",
				            width: 30,
				            labelColor: "#666",
				            startAngle: 0.8,
				            endAngle: 0.2,
				            startNumber: 0,
				            endNumber: 100,
				            labelFormat: "",
				            splitLine: {
				              fixRadius: 10,
				              splitNumber: 10,
				              width: 20,
				              color: "#FFFFFF",
				              childNumber: 5,
				              childWidth: 12
				            },
				            pointer: {
				              width: 12,
				              color: "#f27674"
				            }
				          }
				        }
				      },
					  showPop:false,
					  active:0,
					  index:0,
					  text:'本月',
					  startTime:'',
					  endTime:''
					  
				
			}
		},
	
		onLoad() {
			uni.$on('connectStatusChange',(connectStatus)=>{
				   var connectStr = ''
				   if (connectStatus == true) {
					   connectStr = '已连接'
					   this.getRegistrationID()
				   }else {
					   connectStr = '未连接'
				   }
				   console.log('监听到了连接状态变化 --- ', connectStr) 
				   this.connectStatus = connectStr
			    })  
			// this.getRegistrationID()
			this.getUser()
			// this.initData()
			this.getVersions()
		    this.getServerData()
			this.getclid()
			this.getindexInfo()
			this.checked(3)
		  },
		  onUnload() {
		  	// 移除监听事件  
		      uni.$off('connectStatusChange')
		  },
		  
		  onPullDownRefresh(){
			  
			  setTimeout(() => {
			  	 // this.initData()
			  	 this.getServerData()
			  	 this.getVersions()
			      uni.stopPullDownRefresh()
			  }, 1000)
		  },
		methods:{
			 async getclid(){
			 				 var that=this
			 				await uni.getPushClientId({
			 					
			 					success:async  (res) => {
			 						let push_clientid = res.cid
			 								this.clid=push_clientid
			 						console.log('客户端推送标识:',push_clientid)
			 						await addregidApi({userId:this.$store.getters.userid,username:this.$store.getters.name,registrationId:this.clid}) 
			 					},
			 					fail(err) {
			 						console.log("客户端推送标识失败",err)
			 					}
			 				})
			 				
			 			},
			saomaFn(){
				uni.navigateTo({
					url:"/pages/backmachine/backmachine"
				})
			},
			map(){
				uni.chooseLocation({
					success: function (res) {
						console.log('位置名称：' + res.name);
						console.log('详细地址：' + res.address);
						console.log('纬度：' + res.latitude);
						console.log('经度：' + res.longitude);
					}
				});
			},
			// pages/questions/index
			question(){
				uni.navigateTo({
					url:'/pages/questions/index'
				})
			},
			// follow(){
			// 	uni.navigateTo({
			// 		url:"/pages/follow/index"
			// 	})
			// },
			customer(){
				uni.navigateTo({
					url:"/pages/customer/index"
				})
			},
			projectRemarks(){
				uni.navigateTo({
					url:"/pages/projectRemarks/index"
				})
			},
			WareHouse(){
				uni.navigateTo({
					url:"/pages/WareHouse/WareHouse"
				})
			},
			projectFiling(){
				uni.navigateTo({
					url:"/pages/projectFiling/index"
				})
			},
			repair(){
				uni.navigateTo({
					url:"/pages/repair/index"
				})
			},
			ebgineeCost(){
				uni.navigateTo({
					url:"/pages/ebgineeCost/ebgineeCost"
				})
			},
			out(){
				uni.navigateTo({
					url:"/pages/out/index"
				})
			},
			backapplication(){
				uni.navigateTo({
					url:"/pages/backapplication/backapplication"
				})
			},
			logistics(){
				uni.navigateTo({
					url:"/pages/logistics/index"
				})
			},
			logisticsFn(){
				uni.navigateTo({
					url:"/pages/logistic/logistic"
				})
			},
			receiptorder(){
				uni.navigateTo({
					url:"/pages/receiptorder/index"
				})
			},
			order(){
				uni.navigateTo({
					url:"/pages/order/index"
				})
			},
			order2(){
				uni.navigateTo({
					url:"/pages/order2/index"
				})
			},
			product(){
				uni.navigateTo({
					url:"/pages/product/product"
				})
			},
			machine(){
				uni.navigateTo({
					url:"/pages/machine/machine"
				})
			},
			backwarehouse(){
				uni.navigateTo({
					url:"/pages/backwarehouse/backwarehouse"
				})
			},
			accountStatement(){
				uni.navigateTo({
					url:"/pages/accountStatement/accountStatement"
				})
			},
			finnalStatement(){
				uni.navigateTo({
					url:"/pages/finnalStatement/finnalStatement"
				})
			},
			toTramsfer(){
				uni.navigateTo({
					url:'/pages/transfer/transfer'
				})
			},
			
			// 获取当前版本号
			getVersions(){
				      if (uni.getSystemInfoSync().platform == "ios"){
						  return  false
					  } 
					  console.log(uni.getSystemInfoSync())
					  uni.setStorage()
					  
						console.log('1111')
						// 获取跟新的信息
						let _this=this
						uni.getStorage({
			 		       key: 'wgtinfoVersion',
						   success:(res)=>{
							   console.log(res)
							   this.wgtinfoVersion=res.data
							   getVersion().then(response=>{
								  console.log(response) 
								  let appdata = response.rows[0]
								 
								  if(appdata.versionNumber != this.wgtinfoVersion){
									  console.log('版本号不对')
									  uni.showModal({
											title: "发现新版本",
											content: "确认下载更新",
											success: (res) => {
												console.log(res);
												if(res.confirm==true){
													// 用户确定时下载app
													this.appdownLoad(appdata.download)
												}else{
													return false
												}
											}
										})
								  }
							   })
						   }
						})
						
			},
			// 下载
			appdownLoad(url){
				const _this=this
				uni.showLoading({title: '安装包下载中……'})
				const downloadTask=uni.downloadFile({
					url: 'https://aliyun-file-demo.oss-cn-hangzhou.aliyuncs.com/ethan/yw1.apk',//服务器 app 的下载下载地址
					success:(downloadResult)=>{
						uni.hideLoading()
						console.log(downloadResult)
						// 本应有个判断  成功执行
						if(downloadResult.statusCode==200){
							uni.showModal({
								title:'',
								content: '下载成功，是否允许安装新版本？',
								confirmText: '确定',
								success: function(res){
									if(res.confirm==true){
										// 确认下载
										plus.runtime.install( //安装软件
											downloadResult.tempFilePath, {
												force: true
											},
											function(res) {
												plus.runtime.restart();
											}
										)
									}
								},
								fail: err => {
									uni.hideLoading();
									uni.showToast({title:err})
									console.log(err)
								},
							})
						}
						
					}
				})
				
			},
			getUser(){
				getUserProfile().then( response=>{
					this.name=response.data.userName
					this.userId=response.data.userId
					this.jpushModule.getRegistrationID(async result=>{
						let registerID = result.registerID
						console.log("registerID:"+registerID)
						this.registrationID = registerID
						// 绑定regid
						await addregidApi({userId:this.userId,username:this.name,registrationId:this.registrationID}) 
						 
					})	
					
				})
				
			},
			// 获取首页数据
			async getindexInfo(){
				let res= await getindexInfo()
				let res1=await getsmplenessInfo({startTime:'',endTime:'',salesmanId:'',orderStatus:''})
				this.infomation=res1.data
				console.log(this.infomation);
			},
			
			// 扫码入库
			saoma(){
				// searchMachineApi
				var that =this
				uni.scanCode({
					scanType: ['qrCode'],
						success: function (res) {
							// console.log(res.result);
							// res.result
							that.form.machineNo=res.result
							that.postSearchMachine()
							
						}
				})
			},
			async postSearchMachine(){
				console.log('111');
				console.log(this.form.machineNo);
				 searchMachineApi(this.form).then(res=>{
					 console.log(res);
					 if(res.code==200){
						 this.$refs.uToast.show({
							 type:'success',
							 message:'扫码入库成功！',
						 })
					 }else{
						 this.$refs.uToast.show({
							 type:'error',
							 message:'扫码入库失败！',
						 })
					 }
				 })
			
				
			},
			 getServerData() {
			      //模拟从服务器获取数据时的延时
			      setTimeout(() => {
			        //模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
			        let res = {
			            categories: [{"value":0.2,"color":"#1890ff"},{"value":0.8,"color":"#2fc25b"},{"value":1,"color":"#f04864"}],
			            series: [
			              {
			                name: "完成率",
			                data: 0.2
			              }
			            ]
			          };
			        this.chartData = JSON.parse(JSON.stringify(res));
			      }, 100);
			    },
				 // 打开遮罩层
				openSearch(){
					this.showPop=true
				},
				async checked(val){
					this.active=val
					if(val==1){
						// 今天
						this.startTime=this.getDateStr(new Date())
						this.text="今日"
						this.showPop=false
					    let res=await getsmplenessInfo({startTime:this.startTime})
						this.infomation=res.data
						
					}else if(val==2){
						this.text="本周"
						this.showPop=false
						await this.getweekTime()
						let res=await getsmplenessInfo({starTime:this.startTime,endTime:this.endTime})
						this.infomation=res.data
					}else if(val==3){
						this.text="本月"
						this.showPop=false
						await this.getmonthTime()
						let res=await getsmplenessInfo({starTime:this.startTime,endTime:this.endTime})
						this.infomation=res.data
					}
				},
				closePop(){
					this.showPop=false
				},
				getDateStr(now) {
							var year = now.getFullYear(); // 年
							var month = now.getMonth() + 1; // 月
							var day = now.getDate(); // 日
							if(day < 10) {
								day = '0' + day;
							}
							
							if(month < 10) {
								month = '0' + month;
							}		
							return year + "-" + month + "-" + day;
				
				},
				
				// 获取本周时间
				getweekTime(){
					var now = new Date();
					var nowDayOfWeek = now.getDay() == 0 ? 6 : (now.getDay()-1);
					var startTime = this.getDateStr(new Date(now.getTime() - nowDayOfWeek * 24 * 60 * 60 * 1000)) + ' 00:00:00';
					var endTime = this.getDateStr(now) + ' 23:59:59';
					this.startTime=startTime
					this.endTime=endTime
				},
				// 获取本月
				getmonthTime(){
					var now = new Date();
					var nowDay = now.getDate() - 1;
					var startTime = this.getDateStr(new Date(now.getTime() - nowDay * 24 * 60 * 60 * 1000)) + ' 00:00:00';
					var endTime = this.getDateStr(now) + ' 23:59:59';
					this.startTime=startTime
					this.endTime=endTime
				},
				
				
				
				
				 
		}
	}
</script>

<style lang="scss" scoped>
	.module{
		display: flex;
		justify-content: flex-start;   /* 左对齐 */
		  flex-wrap: wrap;   /* 换行 */
		  background-color: #fff;
	}
	.module-item{
	    width: calc((100% ) / 4);
		display: flex;
		flex-direction: column;
		align-items:center;
		padding: 15px 0;
		
	}
	.module-item:nth-of-type(4n+0) {
	  margin-right: 0;
	
	}
	.container{
		margin-bottom: 100px;
	}
	 .charts-box {
	    width: 100%;
		padding: 20px 10px;
	    height: 300px;
	  }
	
	// 简报看板
	.briefing{
		background-color: #fff;
		margin-top: 4px;
	}
	// 看板中间边框
	.border{
		border-right: solid 1px #c3c3c3;
	}
	.board-Box{
		display: flex;
		flex-wrap: wrap;
		.board{
			width: 50%;
			min-height: 30px;
			padding: 10px;
			display: flex;
			.icon{
				margin: 10px;
				width: 30px;
				height: 25px;
				text-align: center;
				line-height: 25px;
				background-color: #fff;
				border-radius: 15px;
			}
			.data{
				width: 100%;
				margin-left: 5px;
				margin-top: 4px;
				font-size: 12px;
				.title{
					font-weight: 600;
					margin-bottom: 3px;
				}
				.number{
					color:#1b88f4;
				}
			}
		}
	}
	// 业绩目标
	.achievement{
		.target{
			display: flex;
			justify-content: space-around;
		}
		.details{
			margin-top: 10px;
			padding: 10px;
			border-top: solid 1px #c3c3c3;
			text-align: center;
			color:#fd9540 ;
			font-size: 14px;
		}
	}
	// 遗忘提醒
	.RemindBox{
		padding: 10px 0;
		display: flex;
		flex-wrap: wrap;
		.remind{
			width: 40%;
			min-height: 40px;
			margin: 0px 5%;
			padding: 25px 0px;
			border: solid 1px #c3c3c3;
			border-radius: 5px;
			text-align: center;
			margin-top: 10px;
			.color{
				color:#2b8ae8;
				font-size: 16px;
			}
			.words{
				font-size: 14px;
				color:#c3c3c3
			}
		}
	}
	// 客户
	.customer{
		display: flex;
		flex-wrap: wrap;
		border-top: solid 1px #c3c3c3;
		.customerBox{
			width: 50%;
			min-height:20px;
			text-align: center;
			margin: 10px 0;
			.desc{
				font-size: 14px;
				font-weight: 500;
				margin-bottom: 5px;
			}
			.number{
				color:#2b8ae8;
				font-size: 12px;
				
			}
		}
	}
	// 资金管理
	.capitalBox{
		display: flex;
		flex-wrap: wrap;
		
		.capital{
			width: 50%;
			display: flex;
			padding: 13px  0 0 30px;
			.icon,.desc{
				vertical-align: middle;
			}
			.desc{
				margin-left: 9px;
				font-size: 12px;
				.color{
					color: #2b8ae8;
					font-size: 14px;
				}
			}
			
			
		}
	}
	// PK榜
	.PK{
		.title{
			margin-top: 15px;
			text-align: center;
		}
		.middle-box{
			text-align: center;
			min-height: 200px;
			line-height: 200px;
		}
		.details{
			margin-top: 10px;
			padding: 10px;
			border-top: solid 1px #eee;
			text-align: center;
			color:#fd9540 ;
			font-size: 14px;
		}
	}
	.timeSearch{
		display: flex;
		justify-content: space-between;
		 flex-wrap: wrap;
		 padding-top: 10px;
		.timeItem{
			width: calc((100% ) / 4);
			text-align: center;
			background-color: #e6e6e6;
			height: 25px;
			line-height: 25px;
			margin: 5px;
			border-radius: 5px;
		}
		 
		.bcolor1{
			background-color: #5387f5 !important
		}
	}
</style>